<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
<style>
    .el-table .warning-row {
        background: oldlace;
    }

    .el-table .success-row {
        background: #f0f9eb;
    }
</style>
</head>
<body>
    <div id="app">
        <template>
            <el-table :data="weapons" style="width: 100%" :row-class-name="tableRowClassName">
                <el-table-column prop="id" label="编号" width="100"></el-table-column>
                <el-table-column prop="type" label="兵器类型" width="100"></el-table-column>
                <el-table-column prop="range" label="攻击范围" width="100"></el-table-column>
            </el-table>
        </template>
    </div>
    <script>
//        export default {
//            methods: {
//                tableRowClassName({row, range}) {
//                    if (range === "近战") {
//                        return 'warning-row';
//                    } else if (range === "远程") {
//                        return 'success-row';
//                    }
//                    return '';
//                }
//            }
//        }
    </script>
</body>
</html>